package priv.yiyuan.example.design;

import java.io.IOException;

/**
 * 数据库读取适配器
 *
 * @author YiYuan
 * @data 2025/8/8
 * @apoNote
 */
public class DatabaseReaderAdapter implements DataReader {

    private final DatabaseAccessor databaseAccessor;

    private final String query;

    public DatabaseReaderAdapter(DatabaseAccessor databaseAccessor, String query) {
        this.databaseAccessor = databaseAccessor;
        this.query = query;
    }

    @Override
    public String read() throws IOException {
        return databaseAccessor.fetchDataFromDB(query);
    }

    @Override
    public String getSourceInfo() {
        return "Database query: " + query;
    }
}
